/*
 * @Author: Zhouhai 497675647@qq.com
 * @Date: 2022-10-08 11:44:43
 * @LastEditors: Zhouhai 497675647@qq.com
 * @LastEditTime: 2022-10-08 11:57:12
 */
import { CustomFormConfig, TText } from "@/type.d/formItems";
import { ProFormText } from "@ant-design/pro-form"

export const RenderText: (itemconfig: CustomFormConfig, disabled: boolean) => JSX.Element = (itemconfig, disabled) => {
  const placeholder = disabled ? "" : (itemconfig.placeholder || `请输入${itemconfig.title}`);
  const config: TText = itemconfig.config as TText;
  return <ProFormText
    key={itemconfig.fieldId}
    width="md"
    colProps={{ md: 8, xl: 6 }}
    name={itemconfig.fieldId}
    label={itemconfig.title}
    tooltip={config?.tooltip}
    placeholder={placeholder}
  />
}